package com.java.javadome.controller;

import com.java.javadome.constant.ActivitesEnum;
import com.java.javadome.service.TUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private TUserService service;

    @GetMapping("/{uid}")
    public Object checkWallet(@PathVariable Integer uid){
        return service.getById(uid).getWallet();
    }

    @PutMapping("/consume/{uid}/{amounts}")
    public Object consume(@PathVariable Integer uid,@PathVariable Long amounts){
        return service.createOrder(ActivitesEnum.消费,uid,amounts);
    }
    @PutMapping("/refund/{uid}/{amounts}")
    public Object refund(@PathVariable Integer uid,@PathVariable Long amounts){
        return service.createOrder(ActivitesEnum.退款,uid,amounts);
    }
}
